home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / LgcyPlus / disk2 / RADIOBTN._ / RADIOBTN.
Encoding:
Text File  |  2001-03-02  |  7.7 KB  |  241 lines

  1. 10    ! ******************************************************************
  2. 20    ! Example: RADIOBUTTON Widget
  3. 30    !
  4. 40    ! This program generates a panel with two tab groups of RADIOBUTTON
  5. 50    ! widgets. You can set buttons and observe their behavior. A
  6. 60    ! PRINTER widget is used to display the state of the buttons used.
  7. 70    !
  8. 80    ! ******************************************************************
  9. 90    !
  10. 100   ! Define colors
  11. 110   !
  12. 120   INTEGER Black,White,Red,Yellow,Green,Cyan,Blue,Magenta
  13. 130   DATA 0,1,2,3,4,5,6,7
  14. 140   READ Black,White,Red,Yellow,Green,Cyan,Blue,Magenta
  15. 150   !
  16. 160   ! Set the PRINTER widget handle COMmon
  17. 170   !
  18. 180   COM @Printer
  19. 190   !
  20. 200   ! Variables for display and widget handling
  21. 210   !
  22. 220   INTEGER Nlines,D(1:4)               ! Used for display setup
  23. 230   REAL Dw,Dh                          ! Display dimensions
  24. 240   REAL Px,Py,Pw,Ph,Iw,Ih              ! Main PANEL parameters
  25. 250   REAL Gaph,Gapw,Bh,Bw,Sh,Sw,Prh,Prw  ! Widget dimensions
  26. 260   REAL R1,R2,R3,R4,R5,C1,C2,C3,C4,C5  ! Widget coordinates
  27. 270   !
  28. 280   ! Set up display
  29. 290   !
  30. 300   STATUS CRT,13;Nlines
  31. 310   GESCAPE CRT,3;D(*)
  32. 320   Dw=D(3)-D(1)
  33. 330   Dh=(D(4)-D(2))*((Nlines-7)/Nlines)
  34. 340   !
  35. 350   ! Set up PANEL coordinates
  36. 360   !
  37. 370   Pw=Dw*.5
  38. 380   Ph=Dh*.65
  39. 390   Px=(Dw-Pw)
  40. 400   Py=(Dh-Ph)
  41. 410   !
  42. 420   ! Build PANEL widget and add SYSTEM MENU to PANEL
  43. 430   !
  44. 440   CLEAR SCREEN
  45. 450   ASSIGN @Main TO WIDGET "PANEL";SET ("VISIBLE":0)
  46. 460   CONTROL @Main;SET ("RESIZABLE":0,"MAXIMIZABLE":0)
  47. 470   CONTROL @Main;SET ("X":Px/4,"Y":Py/2,"WIDTH":1.3*Pw,"HEIGHT":1.5*Ph)
  48. 480   CONTROL @Main;SET ("TITLE":" Example: RADIOBUTTON Widget")
  49. 490   CONTROL @Main;SET ("SYSTEM MENU":"Quit")
  50. 500   !
  51. 510   ! Get interior dimensions
  52. 520   !
  53. 530   STATUS @Main;RETURN ("INSIDE WIDTH":Iw,"INSIDE HEIGHT":Ih)
  54. 540   !
  55. 550   ! Set up widget coordinates and dimensions
  56. 560   !
  57. 570   Gaph=Ih*.03                     ! Vertical gap
  58. 580   Gapw=Iw*.03                     ! Horizontal gap
  59. 590   Bh=Ih*.15                       ! Button height
  60. 600   Bw=(Iw-Gapw*6)/5                ! Button width
  61. 610   Sh=Gaph                         ! Separator height
  62. 620   Prh=Ih-((Bh+Sh)*2+Gaph*6)       ! Printer height
  63. 630   Prw=(Iw-2*Gapw)                 ! Printer width
  64. 640   Sw=Prw                          ! Separator width
  65. 650   !
  66. 660   R1=Gaph         ! Top row
  67. 670   R2=R1+Bh+Gaph   ! Row 2 = row 1 + button height + gap
  68. 680   R3=R2+Sh+Gaph   ! Row 3 = row 2 + button height + gap
  69. 690   R4=R3+Bh+Gaph   ! Row 4 = row 3 + button height + gap
  70. 700   R5=R4+Sh+Gaph   ! Row 5 = row 4 + button height + gap
  71. 710   !
  72. 720   C1=Gapw         ! Left column
  73. 730   C2=C1+Bw+Gapw   ! Col 2 = col 1 + button width + gap
  74. 740   C3=C2+Bw+Gapw   ! Col 3 = col 2 + button width + gap
  75. 750   C4=C3+Bw+Gapw   ! Col 4 = col 3 + button width + gap
  76. 760   C5=C4+Bw+Gapw   ! Col 5 = col 4 + button width + gap
  77. 770   Pw=C5+Bw+Gapw   ! Panel width = col 5 + button width + gap
  78. 780   !
  79. 790   ! Set up first tab group of RADIOBUTTONs. Set tab stop on A1.
  80. 800   !
  81. 810   ASSIGN @A1 TO WIDGET "RADIOBUTTON";PARENT @Main
  82. 820   CONTROL @A1;SET ("LABEL":"A1","TAB STOP":1)
  83. 830   CONTROL @A1;SET ("X":C1,"Y":R1,"WIDTH":Bw,"HEIGHT":Bh)
  84. 840   !
  85. 850   ! No tab stop on A2
  86. 860   !
  87. 870   ASSIGN @A2 TO WIDGET "RADIOBUTTON";PARENT @Main
  88. 880   CONTROL @A2;SET ("LABEL":"A2","TAB STOP":0)
  89. 890   CONTROL @A2;SET ("X":C2,"Y":R1,"WIDTH":Bw,"HEIGHT":Bh)
  90. 900   !
  91. 910   ! No tab stop on A3
  92. 920   !
  93. 930   ASSIGN @A3 TO WIDGET "RADIOBUTTON";PARENT @Main
  94. 940   CONTROL @A3;SET ("LABEL":"A3","TAB STOP":0)
  95. 950   CONTROL @A3;SET ("X":C3,"Y":R1,"WIDTH":Bw,"HEIGHT":Bh)
  96. 960   !
  97. 970   ! No tab stop on A4
  98. 980   !
  99. 990   ASSIGN @A4 TO WIDGET "RADIOBUTTON";PARENT @Main
  100. 1000  CONTROL @A4;SET ("LABEL":"A4","TAB STOP":0)
  101. 1010  CONTROL @A4;SET ("X":C4,"Y":R1,"WIDTH":Bw,"HEIGHT":Bh)
  102. 1020  !
  103. 1030  ! No tab stop on A5
  104. 1040  !
  105. 1050  ASSIGN @A5 TO WIDGET "RADIOBUTTON";PARENT @Main
  106. 1060  CONTROL @A5;SET ("LABEL":"A5","TAB STOP":0)
  107. 1070  CONTROL @A5;SET ("X":C5,"Y":R1,"WIDTH":Bw,"HEIGHT":Bh)
  108. 1080  !
  109. 1090  ! Separator to mark off first tab group
  110. 1100  !
  111. 1110  ASSIGN @Sep1 TO WIDGET "SEPARATOR";PARENT @Main
  112. 1120  CONTROL @Sep1;SET ("X":C1,"Y":R2,"WIDTH":Sw,"HEIGHT":Sh)
  113. 1130  !
  114. 1140  ! Set up second tab group, set TAB STOP on B1
  115. 1150  !
  116. 1160  ASSIGN @B1 TO WIDGET "RADIOBUTTON";PARENT @Main
  117. 1170  CONTROL @B1;SET ("LABEL":"B1","TAB STOP":1)
  118. 1180  CONTROL @B1;SET ("X":C1,"Y":R3,"WIDTH":Bw,"HEIGHT":Bh)
  119. 1190  !
  120. 1200  ! B2, no tab stop
  121. 1210  !
  122. 1220  ASSIGN @B2 TO WIDGET "RADIOBUTTON";PARENT @Main
  123. 1230  CONTROL @B2;SET ("LABEL":"B2","TAB STOP":0)
  124. 1240  CONTROL @B2;SET ("X":C2,"Y":R3,"WIDTH":Bw,"HEIGHT":Bh)
  125. 1250  !
  126. 1260  ! B3, no tab stop
  127. 1270  !
  128. 1280  ASSIGN @B3 TO WIDGET "RADIOBUTTON";PARENT @Main
  129. 1290  CONTROL @B3;SET ("LABEL":"B3","TAB STOP":0)
  130. 1300  CONTROL @B3;SET ("X":C3,"Y":R3,"WIDTH":Bw,"HEIGHT":Bh)
  131. 1310  !
  132. 1320  ! B4, no tab stop
  133. 1330  !
  134. 1340  ASSIGN @B4 TO WIDGET "RADIOBUTTON";PARENT @Main
  135. 1350  CONTROL @B4;SET ("LABEL":"B4","TAB STOP":0)
  136. 1360  CONTROL @B4;SET ("X":C4,"Y":R3,"WIDTH":Bw,"HEIGHT":Bh)
  137. 1370  !
  138. 1380  ! B5, no tab stop
  139. 1390  !
  140. 1400  ASSIGN @B5 TO WIDGET "RADIOBUTTON";PARENT @Main
  141. 1410  CONTROL @B5;SET ("LABEL":"B5","TAB STOP":0)
  142. 1420  CONTROL @B5;SET ("X":C5,"Y":R3,"WIDTH":Bw,"HEIGHT":Bh)
  143. 1430  !
  144. 1440  ! Separator for second tab group
  145. 1450  !
  146. 1460  ASSIGN @Sep2 TO WIDGET "SEPARATOR";PARENT @Main
  147. 1470  CONTROL @Sep2;SET ("X":C1,"Y":R4,"WIDTH":Sw,"HEIGHT":Sh)
  148. 1480  !
  149. 1490  ! PRINTER widget
  150. 1500  !
  151. 1510  ASSIGN @Printer TO WIDGET "PRINTER";PARENT @Main,SET ("TAB STOP":1)
  152. 1520  CONTROL @Printer;SET ("TAB STOP":1)
  153. 1530  CONTROL @Printer;SET ("BACKGROUND":White)
  154. 1540  CONTROL @Printer;SET ("PEN":Black)
  155. 1550  CONTROL @Printer;SET ("X":C1,"Y":R5,"WIDTH":Prw,"HEIGHT":Prh)
  156. 1560  !
  157. 1570  ! Set up events
  158. 1580  !
  159. 1590  ON EVENT @A1,"CHANGED" GOSUB A1
  160. 1600  ON EVENT @A2,"CHANGED" GOSUB A2
  161. 1610  ON EVENT @A3,"CHANGED" GOSUB A3
  162. 1620  ON EVENT @A4,"CHANGED" GOSUB A4
  163. 1630  ON EVENT @A5,"CHANGED" GOSUB A5
  164. 1640  !
  165. 1650  ON EVENT @B1,"CHANGED" GOSUB B1
  166. 1660  ON EVENT @B2,"CHANGED" GOSUB B2
  167. 1670  ON EVENT @B3,"CHANGED" GOSUB B3
  168. 1680  ON EVENT @B4,"CHANGED" GOSUB B4
  169. 1690  ON EVENT @B5,"CHANGED" GOSUB B5
  170. 1700  !
  171. 1710  ON EVENT @Main,"SYSTEM MENU" GOTO Finis
  172. 1720  !
  173. 1730  ! Turn on panel
  174. 1740  !
  175. 1750  CONTROL @Main;SET ("VISIBLE":1)
  176. 1760  !
  177. 1770  ! Main loop, wait for event
  178. 1780  !
  179. 1790  LOOP
  180. 1800    WAIT FOR EVENT
  181. 1810  END LOOP
  182. 1820  STOP
  183. 1830  !
  184. 1840  ! Handlers for buttons
  185. 1850  !
  186. 1860 A1: !
  187. 1870  Show_value(@A1,"Button A1, VALUE:")
  188. 1880  RETURN
  189. 1890  !
  190. 1900 A2: !
  191. 1910  Show_value(@A2,"Button A2, VALUE:")
  192. 1920  RETURN
  193. 1930  !
  194. 1940 A3: !
  195. 1950  Show_value(@A3,"Button A3, VALUE:")
  196. 1960  RETURN
  197. 1970  !
  198. 1980 A4: !
  199. 1990  Show_value(@A4,"Button A4, VALUE:")
  200. 2000  RETURN
  201. 2010  !
  202. 2020 A5: !
  203. 2030  Show_value(@A5,"Button A5, VALUE:")
  204. 2040  RETURN
  205. 2050  !
  206. 2060 B1: !
  207. 2070  Show_value(@B1,"Button B1, VALUE:")
  208. 2080  RETURN
  209. 2090  !
  210. 2100 B2: !
  211. 2110  Show_value(@B2,"Button B2, VALUE:")
  212. 2120  RETURN
  213. 2130  !
  214. 2140 B3: !
  215. 2150  Show_value(@B3,"Button B3, VALUE:")
  216. 2160  RETURN
  217. 2170  !
  218. 2180 B4: !
  219. 2190  Show_value(@B4,"Button B4, VALUE:")
  220. 2200  RETURN
  221. 2210  !
  222. 2220 B5: !
  223. 2230  Show_value(@B5,"Button B5, VALUE:")
  224. 2240  RETURN
  225. 2250  !
  226. 2260 Finis: !
  227. 2270  ASSIGN @Main TO *     ! Delete PANEL widget
  228. 2280  END
  229. 2290  !
  230. 2300  ! ********** End of Main Program ****************
  231. 2310  !
  232. 2320  ! SUB to handle display of button inputs
  233. 2330  ! on PRINTER widget
  234. 2340  !
  235. 2350  SUB Show_value(@B,Text$)
  236. 2360    COM @Printer
  237. 2370    INTEGER Checked
  238. 2380    STATUS @B;RETURN ("VALUE":Checked)
  239. 2390    CONTROL @Printer;SET ("APPEND TEXT":Text$&VAL$(Checked))
  240. 2400  SUBEND
  241.